<template>
	<view id="myView">
		这是test组件{{num}}
		这是父组件传递过来的数据{{title}}
		<button @click="sendNum">给父组件传值</button>
	</view>
</template>

<script>
	export default {
		name:"test",
		data() {
			return {
				num: 3,
				intId: null
			};
		},
		props: ['title'],
		methods: {
			sendNum () {
				console.log('给父组件传值')
				this.$emit('myEvent', this.num)
			}
		},
		beforeCreate() {//拿不到数据
			console.log('实例已经开始初始化了')
			console.log(this.num)
		},
		created() { //可以拿到数据
			console.log('created', this.num)
			this.intId = setInterval(() => {
				console.log('执行定制器')
			}, 1000)
		},
		beforeMount() {//没有渲染到页面上
			console.log('beforeMount', document.getElementById('myView'))
		},
		mounted() {//渲染完成
			console.log('mounted', document.getElementById('myView'))
		},
		destroyed() {
			console.log('组件销毁了')
			clearInterval(this.intId)
		}
	}
</script>

<style>

</style>
